package com.example.buyticketlishi.wightview;

import android.app.Dialog;
import android.content.Context;
import android.view.KeyEvent;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.LinearInterpolator;

import com.example.buyticketlishi.R;

/**
 * Data：2019/4/20-14:58
 * Author: dyx
 */
public class LosLoadDialog extends Dialog {
    public LosLoadDialog(Context context) {
        super(context, R.style.loading_dialog);
        initView();

    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        switch (keyCode) {
            case KeyEvent.KEYCODE_BACK:
                if (LosLoadDialog.this.isShowing()) LosLoadDialog.this.dismiss();
                break;
        }
        return true;
    }

    private void initView() {
        setContentView(R.layout.dialog_loading);
        Animation animation = AnimationUtils.loadAnimation(getContext(), R.anim.loadingdialog_anim);
        animation.setInterpolator(new LinearInterpolator());
        findViewById(R.id.loading_dialog_img).startAnimation(animation);
        setCanceledOnTouchOutside(true);
        WindowManager.LayoutParams attributes = getWindow().getAttributes();
       // getWindow().setBackgroundDrawableResource(android.R.color.white);
        attributes.alpha = 0.8f;
        getWindow().setAttributes(attributes);

        setCancelable(false);

    }

}
